home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / dbase / do1beta.zip / FRIEND.DO < prev    next >
Text File  |  1991-07-23  |  758b  |  37 lines

  1. /*
  2.     demo of a private method for a class
  3.     private methods are only callable from within a method for a class
  4. */
  5. inherit(Nil,Temp,[]);
  6. inherit(Nil,Temp2,[]);
  7.  
  8. /*
  9.     defining class Temp2 as a friend of class Temp
  10.     means that methods of Temp2 can access variable and private
  11.     methods of Temp
  12. */
  13. friend(Temp,Temp2); 
  14.  
  15. /*
  16.     define a private method for Temp
  17. */
  18. private Temp::testPrivate(self)
  19. {
  20.     ? "within Temp::testPrivate()";
  21. }
  22.  
  23. /*
  24.     define a public method for Temp2 that creates a variable of
  25.     type Temp and calls a private method for it
  26. */
  27. method Temp2::test(self)
  28. {
  29.     ? "enter Temp2::test";
  30.     v = new(Temp);
  31.     testPrivate(v); % this won't work unless Temp2 is a friend of Temp !
  32.     ? "exit Temp2::test";
  33. }
  34.  
  35. v = new(Temp2);
  36. test(v);
  37.